<template>
  <el-form ref="form" :model="form" label-width="100px">
    <el-row>
      <el-col :span="12">
        <el-form-item label="业务员id">
          <el-input v-model="form.empId" class="input_width" disabled></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="产品选择">
          <el-select v-model="form.proId" placeholder="请选择产品" class="input_width">
            <el-option
              v-for="item in products"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
            <!-- <el-option label="区域二" value="beijing"></el-option> -->
          </el-select>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="客户id">
          <el-input v-model="form.cusId" class="input_width"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="贷款金额">
          <el-input v-model="form.money" class="input_width"></el-input>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="是否确定">
          <el-input v-model="form.confirm" class="input_width"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="收款账号">
          <el-input v-model="form.acceptAccount" class="input_width"></el-input>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12" :offset="6">
        <el-form-item>
          <el-button type="primary" @click="onSubmit">立即创建</el-button>
          <el-button>
            <router-link to="/contractManage">取消</router-link>
          </el-button>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>
<script>
import server from "@/global.js";
export default {
  data() {
    return {
      form: {
        proId: "",
        empId: 1,
        cusId: "",
        money: "",
        confirm: "",
        acceptAccount: "",
      },
      products: [],
    };
  },
  created: function () {
    //发送请求得到所有产品的信息
    this.$axios({
      url: server.server + "/api/product/getAll",
      method: "post",
    }).then((r) => {
      // console.log(r);
      if (r.data.code == 200) {
        this.products = r.data.data;
      }
    });
  },
  methods: {
    onSubmit() {
      console.log(this.form);
      this.$axios({
        url: server.server + "/api/contract/add",
        method: "post",
        data: this.form,
      }).then((r) => {
        window.alert(r.data.message);
      });
    },
  },
};
</script>

<style>
.input_width {
  width: 250px;
}
</style>